﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Transactions;
using System.Data;
using Credisoft.Models;

namespace Credisoft.Models.Credisoft_DAO
{
    public class GrantingCreditDAO
    {
        //Insertar Estados Financieros

        public int insertarEdificio(estadosfinancieros finantialStatements)
        {
            int exito = 0;
            for (int i = 0; i < 100; i++)
            {
                //INICIAMOS CON TRANSACTION
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (credisoftEntities db = new credisoftEntities())
                    {
                        try//no borrar este TRY-CATCH: es neceario para Transaction
                        {
                           
                                db.estadosfinancieros.Add(finantialStatements);
                                exito = db.SaveChanges();//<- GUARDAMOS EN LA BASE DE DATOS
                                transaction.Complete();
                                return finantialStatements.idestadosfinancieros;

                            
                        }
                        catch (UpdateException e)
                        {
                        }
                    }
                }//Fin del Transaction

            }//Fin del For
            return exito;
        }


    }
}